-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC FS 1126 Allow lower-case DU cases when RequireQualifiedAccess is specified #13432
RFC FS 1126 Allow lower-case DU cases when RequireQualifiedAccess is specified #13432
Conversation
let hasRequireQualifiedAccessAttribute = HasFSharpAttribute cenv.g cenv.g.attrib_RequireQualifiedAccessAttribute tycon.Attribs | ||
|
||
if not hasRequireQualifiedAccessAttribute then | ||
CheckUnionCaseName cenv id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need these parts of CheckUnionCaseName because the compiled form must generate a type and enum case for these - better to pass in hasRequireQualifiedAccessAttribute
to that routine?
if name = "Tags" then
errorR(Error(FSComp.SR.tcUnionCaseNameConflictsWithGeneratedType(name, "Tags"), id.idRange))
CheckNamespaceModuleOrTypeName g id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated based on your suggestion.
|
||
[<RequireQualifiedAccess>] | ||
type DU1 = | ||
| a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case with a dodgy lower case name that is not a valid type name for .NET, e.g.
type DU =
| ``not.allowed``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more testing. Thanks for pointing this out .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vzarytovskii I was wondering if should put this behind a preview flag ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's put it under preview version.
811eac2
to
a9bf35c
Compare
@dsyme this is ready for another review . Added more testing and put the feature under the preview. |
// #Conformance #TypesAndModules #Unions | ||
// This testcase verifies that lower-case discriminated union are not allowed | ||
//<Expects status="error"></Expects> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: those are actually not required for newly written tests, they are there for the tests which were auto-migrated from the old framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool I will remove them :)
@edgarfgp thank you a lot for this addition! Sorry it took long to merge it. |
@vzarytovskii No worries . I already looking for the next contribution to help the compiler 😀 |
* ValRepInfoForDisplay added for improved quick info for functions defined in expressions * Update * Update QuickInfoTests.fs * Update QuickInfoTests.fs * Update * add identifier analysis script (#13486) * add identifier analysis script * add identifier analysis script * Update fantomas alpha 11 (#13481) * Allow lower-case DU cases when RequireQualifiedAccess is specified (#13432) * Allow lower-case DU cases when RequireQualifiedAccess is specified * Fix PR suggestions and Add more testing * Protect feature under preview version * Add a NotUpperCaseConstructorWithoutRQA warning to be raised in lang version preview * Fix formatting * regularize some names (#13489) * normalize some names * format code * fix build * Subtraction of two chars, new conversions, and fixes for dynamic operator invocations and QuotationToExpression (#11681) Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com> * Mark backing fields as CompilerGenerated (fixes serialization of fields in FSI multiemit) (#13494) Co-authored-by: Don Syme <donsyme@fastmail.fm> Co-authored-by: Peter Semkin <petersemkin@duck.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com> Co-authored-by: Florian Verdonck <florian.verdonck@outlook.com> Co-authored-by: Petr Semkin <psfinaki@users.noreply.github.com> Co-authored-by: Edgar Gonzalez <edgar.gonzalez@fundourselves.com> Co-authored-by: Hadrian Tang <hadrianwttang@outlook.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Implementation for Allow lower-case DU cases when RequireQualifiedAccess is specified fsharp/fslang-suggestions#131
RFC: https://github.com/fsharp/fslang-design/blob/main/FSharp-7.0/FS-1126-allow-lower-case-du-cases%20when-require-qualified-access-is%20specified.md